Data Overview

Row

ImPACT Test Totals

PCSS Item Description

PCSS Symptom Clusters

Row

Sims - Gender

Sims - Age

Sims - League

Sims - School

Sims - Sport

Sims - Sport Level

Sims - RTL Summary

Sims - RTL Plot

Sims - RTP Summary

Sims - RTP Plot

One Post-Injury Test

Row

Total Symptom Score Histogram

Total Symptom Score Summary

Total Symptom Score Summary - Gender

Total Symptom Score Gender Visual Comparison

Row

Headache-Migraine Cluster Score Histogram

Headache-Migraine Cluster Score Summary

Headache-Migraine Cluster Score Summary - Gender

Headache-Migraine Score Gender Visual Comparison

Row

Cognitive Cluster Score Histogram

Cognitive Cluster Score Summary

Cognitive Cluster Score Summary - Gender

Cognitive Score Gender Visual Comparison

Row

Anxiety-Mood Cluster Score Histogram

Anxiety-Mood Cluster Score Summary

Anxiety-Mood Cluster Score Summary - Gender

Anxiety-Mood Score Gender Visual Comparison

Row

Ocular-Motor Cluster Score Histogram

Ocular-Motor Cluster Score Summary

Ocular-Motor Cluster Score Summary - Gender

Ocular-Motor Score Gender Visual Comparison

Row

Vestibular Cluster Score Histogram

Vestibular Cluster Score Summary

Vestibular Cluster Score Summary - Gender

Vestibular Score Gender Visual Comparison

Row

Sleep Cluster Score Histogram

Sleep Cluster Score Summary

Sleep Cluster Score Summary - Gender

Sleep Score Gender Visual Comparison

Two Post-Injury Tests

Row

Total Symptom Score Test 1

Total Symptom Score Test 1 Summary

Total Symptom Score Test 2

Total Symptom Score Test 2 Summary

Boxplot Comparison

T-Test Results


    Paired t-test

data:  two_impact_test_total_symptom_score_1 and two_impact_test_total_symptom_score_2
t = 49.87, df = 5294, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 9.009614 9.746949
sample estimates:
mean of the differences 
               9.378281 

Row

Headache-Migraine Cluster Score Test 1

Headache-Migraine Cluster Score Test 1 Summary

Headache-Migraine Cluster Score Test 2

Headache-Migraine Cluster Score Test 2 Summary

Boxplot Comparison

T-Test Results


    Paired t-test

data:  two_impact_test_headache_migraine_cluster_score_1 and two_impact_test_headache_migraine_cluster_score_2
t = 51.752, df = 5294, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 2.002734 2.160439
sample estimates:
mean of the differences 
               2.081586 

Row

Cognitive Cluster Score Test 1

Cognitive Cluster Score Test 1 Summary

Cognitive Cluster Score Test 2

Cognitive Cluster Score Test 2 Summary

Boxplot Comparison

T-Test Results


    Paired t-test

data:  two_impact_test_cognitive_cluster_score_1 and two_impact_test_cognitive_cluster_score_2
t = 42.022, df = 5294, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 1.939284 2.129082
sample estimates:
mean of the differences 
               2.034183 

Row

Anxiety-Mood Cluster Score Test 1

Anxiety-Mood Cluster Score Test 1 Summary

Anxiety-Mood Cluster Score Test 2

Anxiety-Mood Cluster Score Test 2 Summary

Boxplot Comparison

T-Test Results


    Paired t-test

data:  two_impact_test_anxiety_mood_cluster_score_1 and two_impact_test_anxiety_mood_cluster_score_2
t = 31.748, df = 5294, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 1.267835 1.434714
sample estimates:
mean of the differences 
               1.351275 

Row

Ocular-Motor Cluster Score Test 1

Ocular-Motor Cluster Score Test 1 Summary

Ocular-Motor Cluster Score Test 2

Ocular-Motor Cluster Score Test 2 Summary

Boxplot Comparison

T-Test Results


    Paired t-test

data:  two_impact_test_ocular_motor_cluster_score_1 and two_impact_test_ocular_motor_cluster_score_2
t = 22.86, df = 5294, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 0.2420710 0.2874852
sample estimates:
mean of the differences 
              0.2647781 

Row

Vestibular Cluster Score Test 1

Vestibular Cluster Score Test 1 Summary

Vestibular Cluster Score Test 2

Vestibular Cluster Score Test 2 Summary

Boxplot Comparison

T-Test Results


    Paired t-test

data:  two_impact_test_vestibular_cluster_score_1 and two_impact_test_vestibular_cluster_score_2
t = 41.724, df = 5294, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 1.487566 1.634247
sample estimates:
mean of the differences 
               1.560907 

Row

Sleep Cluster Score Test 1

Sleep Cluster Score Test 1 Summary

Sleep Cluster Score Test 2

Sleep Cluster Score Test 2 Summary

Boxplot Comparison

T-Test Results


    Paired t-test

data:  two_impact_test_sleep_cluster_score_1 and two_impact_test_sleep_cluster_score_2
t = 42.86, df = 5294, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 1.990160 2.180945
sample estimates:
mean of the differences 
               2.085552 

Three Post-Injury Tests

Row

Total Symptom Score Test 1

Total Symptom Score Test 1 Summary

Total Symptom Score Test 2

Total Symptom Score Test 2 Summary

Total Symptom Score Test 3

Total Symptom Score Test 3 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

Row

Headache-Migraine Cluster Score Test 1

Headache-Migraine Cluster Score Test 1 Summary

Headache-Migraine Cluster Score Test 2

Headache-Migraine Cluster Score Test 2 Summary

Headache-Migraine Cluster Score Test 3

Headache-Migraine Cluster Score Test 3 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

Row

Cognitive Cluster Score Test 1

Cognitive Cluster Score Test 1 Summary

Cognitive Cluster Score Test 2

Cognitive Cluster Score Test 2 Summary

Cognitive Cluster Score Test 3

Cognitive Cluster Score Test 3 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

Row

Anxiety-Mood Cluster Score Test 1

Anxiety-Mood Cluster Score Test 1 Summary

Anxiety-Mood Cluster Score Test 2

Anxiety-Mood Cluster Score Test 2 Summary

Anxiety-Mood Cluster Score Test 3

Anxiety-Mood Cluster Score Test 3 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

Row

Ocular-Motor Cluster Score Test 1

Ocular-Motor Cluster Score Test 1 Summary

Ocular-Motor Cluster Score Test 2

Ocular-Motor Cluster Score Test 2 Summary

Ocular-Motor Cluster Score Test 3

Ocular-Motor Cluster Score Test 3 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

Row

Vestibular Cluster Score Test 1

Vestibular Cluster Score Test 1 Summary

Vestibular Cluster Score Test 2

Vestibular Cluster Score Test 2 Summary

Vestibular Cluster Score Test 3

Vestibular Cluster Score Test 3 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

Row

Sleep Cluster Score Test 1

Sleep Cluster Score Test 1 Summary

Sleep Cluster Score Test 2

Sleep Cluster Score Test 2 Summary

Sleep Cluster Score Test 3

Sleep Cluster Score Test 3 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

Four Post-Injury Tests

Row

Total Symptom Score Test 1

Total Symptom Score Test 1 Summary

Total Symptom Score Test 2

Total Symptom Score Test 2 Summary

Total Symptom Score Test 3

Total Symptom Score Test 3 Summary

Total Symptom Score Test 4

Total Symptom Score Test 4 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

Row

Headache-Migraine Cluster Score Test 1

Headache-Migraine Cluster Score Test 1 Summary

Headache-Migraine Cluster Score Test 2

Headache-Migraine Cluster Score Test 2 Summary

Headache-Migraine Cluster Score Test 3

Headache-Migraine Cluster Score Test 3 Summary

Headache-Migraine Cluster Score Test 4

Headache-Migraine Cluster Score Test 4 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

Row

Cognitive Cluster Score Test 1

Cognitive Cluster Score Test 1 Summary

Cognitive Cluster Score Test 2

Cognitive Cluster Score Test 2 Summary

Cognitive Cluster Score Test 3

Cognitive Cluster Score Test 3 Summary

Cognitive Cluster Score Test 4

Cognitive Cluster Score Test 4 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

Row

Anxiety-Mood Cluster Score Test 1

Anxiety-Mood Cluster Score Test 1 Summary

Anxiety-Mood Cluster Score Test 2

Anxiety-Mood Cluster Score Test 2 Summary

Anxiety-Mood Cluster Score Test 3

Anxiety-Mood Cluster Score Test 3 Summary

Anxiety-Mood Cluster Score Test 4

Anxiety-Mood Cluster Score Test 4 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

Row

Ocular-Motor Cluster Score Test 1

Ocular-Motor Cluster Score Test 1 Summary

Ocular-Motor Cluster Score Test 2

Ocular-Motor Cluster Score Test 2 Summary

Ocular-Motor Cluster Score Test 3

Ocular-Motor Cluster Score Test 3 Summary

Ocular-Motor Cluster Score Test 4

Ocular-Motor Cluster Score Test 4 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

Row

Vestibular Cluster Score Test 1

Vestibular Cluster Score Test 1 Summary

Vestibular Cluster Score Test 2

Vestibular Cluster Score Test 2 Summary

Vestibular Cluster Score Test 3

Vestibular Cluster Score Test 3 Summary

Vestibular Cluster Score Test 4

Vestibular Cluster Score Test 4 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

Row

Sleep Cluster Score Test 1

Sleep Cluster Score Test 1 Summary

Sleep Cluster Score Test 2

Sleep Cluster Score Test 2 Summary

Sleep Cluster Score Test 3

Sleep Cluster Score Test 3 Summary

Sleep Cluster Score Test 4

Sleep Cluster Score Test 4 Summary

Boxplot Comparison

Outliers

ANOVA

Pairwise Comparisons

---
title: "Educational Data Science Capstone Project"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code: embed
    vertical_layout: scroll
    theme: united
---

```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(here)
library(janitor)
library(rio)
library(colorblindr)
library(gghighlight)
library(forcats)
library(ggrepel)
library(gt)
library(knitr)
library(kableExtra)
library(reactable)
library(plotly)
library(glue)
library(fs)
library(rstatix)
library(ggpubr)
library(writexl)
library(remotes)

theme_set(theme_minimal(15) +
            theme(legend.position = "bottom",
                  panel.grid.major.x = element_line(color = "gray60"),
                  panel.grid.minor.x = element_blank(),
                  panel.grid.major.y = element_blank())
          )
```

```{r, include=FALSE}
# all impact data 

impact_all <- read_csv(here("data", "impact_data.csv"))

str(impact_all)


#all clean sims data
sims_concussion_data <- read_csv(here("data", "sims_concussion_data.csv"))

str(sims_concussion_data)

#impact data only

one_impact_test <- read_csv(here("data", "one_post_injury_impact_test.csv"))

str(one_impact_test)

two_impact_test <- read_csv(here("data", "two_post_injury_impact_test.csv"))

three_impact_test <- read_csv(here("data", "three_post_injury_impact_test.csv"))

four_impact_test <- read_csv(here("data", "four_post_injury_impact_test.csv"))

# impact sims merge data

one_impact_sims <- read_csv(here("data", "one_post_injury_test_impact_sims_merge.csv"))

str(one_impact_sims)

two_impact_sims <- read_csv(here("data", "two_post_injury_test_impact_sims_merge.csv"))

three_impact_sims <- read_csv(here("data", "three_post_injury_test_impact_sims_merge.csv"))

four_impact_sims <- read_csv(here("data", "four_post_injury_test_impact_sims_merge.csv"))

# pcss items 

pcss_items <- import(here("data", "pcss_items.xlsx"),
               setclass = "tbl_df") 

pcss_cluster <- import(here("data", "cluster_scores.xlsx"),
               setclass = "tbl_df") 
```

```{r, include=FALSE}
#helpful functions 

mean_2 <- function(x) {
  z <- na.omit(x)
  sum(z) / length(z)
}

my_mean <- function(x) {
  mean(x[x >= 0], na.rm = TRUE)
}

create_react_time <- function(df, var) {
    df %>% 
      summarize(Mean = mean({{var}}),
                SD = sd({{var}}),
                Min = min({{var}}),
                Max = max({{var}}),
                Total = length({{var}})) %>% 
      mutate_if(is.numeric, round, 2) %>% 
      reactable(columns = list(
        Mean = colDef(format = colFormat(separators = TRUE, suffix = " days")),
        SD = colDef(format = colFormat(separators = TRUE, suffix = " days")),
        Min = colDef(format = colFormat(separators = TRUE, suffix = " days")),
        Max = colDef(format = colFormat(separators = TRUE, suffix = " days")),
        Total = colDef(format = colFormat(separators = TRUE, suffix = " concussions"))
      ))
}

create_react <- function(df, var) {
    df %>% 
      summarize(Mean = mean({{var}}),
                SD = sd({{var}}),
                Min = min({{var}}),
                Max = max({{var}}),
                Total = length({{var}})) %>% 
      mutate_if(is.numeric, round, 2) %>% 
      reactable(columns = list(
        Mean = colDef(format = colFormat(separators = TRUE)),
        SD = colDef(format = colFormat(separators = TRUE)),
        Min = colDef(format = colFormat(separators = TRUE)),
        Max = colDef(format = colFormat(separators = TRUE)),
        Total = colDef(format = colFormat(separators = TRUE, suffix = " concussions"))
      ))
}

```


# Data Overview 

Sidebar {.sidebar}
------------

**_Data Description:_** The data for this capstone project was provided by the Hawaii Concussion Awareness and Management Program [(HCAMP)](https://hawaiiconcussion.com/), which is an organization affiliated with the University of Hawaii. The mission of HCAMP is to develop evidence-based interventions to manage concussion. 

The specific goal of this project is to explore trends from two data sets. The first data set contains multiple years of test and symptom severity scores from the Immediate Post-Concussion Assessment and Cognitive Testing [(ImPACT)](https://impactconcussion.com/) software. The second data set contains multiple years of return-to-learn (RTL) and return-to-play (RTP) outcome data from the Hawaii Department of Education Student Information Management System (SIMS). The ImPACT data set is utilized to explore trends in symptom severity, as measured by the [Post-Concussion Symptom Scale (PCSS)](tools/Post-Concussion-Symptom-Scale1.pdf), across individuals who completed post-injury testing following their concussion. The ImPACT data set is divided into four smaller data sets to represent individuals who completed one post-injury test, two post-injury tests, three post-injury tests, and four post-injury tests. Specific to this data set, the following research question is explored: Is there a significant difference between PCSS cluster symptom scores during the recovery process? The six symptom clusters used for this project are adapted from Lumba-Brown et al. (2019) and Harmon et al. (2019). 

The SIMS data set is utilized to explore trends in the duration of time to complete RTL and RTP protocols. The ImPACT and SIMS data sets have been joined corresponding to the number of post-injury tests completed from the ImPACT data set. Although the merger of these data sets did not yield a large number of observations to analyze, the following research question is explored: What is the relationship between symptom severity scores and RTL/RTP duration? 

The top row of the *Data Overview* tab displays information on the number of individuals who completed multiple ImPACT tests as well as information on the PCSS. The bottom row displays information on the complete SIMS data set, consisting of individuals who experienced a documented concussion and were tracked for recovery during the RTL and RTP process. 


Row {.tabset}
-----------------------------------------------------------------------

### ImPACT Test Totals

```{r, include=FALSE}
t_sum_pi <- data.frame("Level" = c("One Post-Injury Test",
                                  "Two Post-Injury Tests",
                                  "Three Post-Injury Tests",
                                  "Four Post-Injury Tests"),
                      "Total" = c(9991,
                                  5295,
                                  2228,
                                  780))
```

```{r, include=FALSE}
t_sum_pi %>% 
  reactable(columns = list(
    Level = colDef(name = "Level",
                   align = "center"),
    Total = colDef(name = "Total", 
                   align = "center",
                   format = colFormat(separators = TRUE, suffix = " individuals"))),
    striped = TRUE,
    outlined = TRUE,
    compact = TRUE,
    highlight = TRUE,
    bordered = TRUE)
```

```{r, include=FALSE}
pi_plot <- ggplot(t_sum_pi, aes(fct_reorder(Level, Total), Total)) +
  geom_col(fill = "blue",
           alpha = 0.7) +
  scale_y_continuous(labels = function(x) format(x, big.mark = ",",
                                                 scientific = FALSE)) +
  coord_flip() +
  labs(x = "",
       y = "Individuals")
```

```{r, include=TRUE}
ggplotly(pi_plot)
```

### PCSS Item Description

```{r}
pcss_items %>% 
  reactable(columns = list(
    Item = colDef(name = "Item",
                   align = "center"),
    Symptom = colDef(name = "Symptom", 
                   align = "center"),
    Cluster = colDef(name = "Cluster",
                     align = "center")),
    striped = TRUE,
    outlined = TRUE,
    compact = TRUE,
    highlight = TRUE,
    bordered = TRUE,
    searchable = TRUE)
```

### PCSS Symptom Clusters

```{r, include=FALSE}
head(pcss_cluster)

pcss_cluster_plot <- ggplot(pcss_cluster, aes(fct_reorder(Cluster, `Total Possible Severity Score`),
                                              `Total Possible Severity Score`)) +
  geom_col(fill = "blue",
           alpha = 0.7) +
  scale_y_continuous(limits = c(0, 30),
                     breaks = c(0, 5, 10, 15, 20, 25, 30)) +
  coord_flip() +
  labs(x = "",
       y = "Total Possible Severity Score",
       caption = "Total Possible Severity Score = 132")
```

```{r, include=TRUE}
ggplotly(pcss_cluster_plot)
```

Row {.tabset}
-----------------------------------------------------------------------

### Sims - Gender 

```{r, include=FALSE}
sims_concussion_data %>% 
  group_by(gender) %>% 
  summarize(total = n()) %>% 
  arrange(desc(total)) %>% 
  reactable(
    columns = list(
      gender = colDef(name = "Gender",
                      align = "center"),
      total = colDef(name = "Total",
                     align = "center",
                     format = colFormat(suffix = " concussions"))),
    pagination = TRUE,
    striped = TRUE,
    outlined = TRUE,
    compact = TRUE,
    highlight = TRUE,
    bordered = TRUE
    )
```

```{r, include=FALSE}
sims_gender <- sims_concussion_data %>% 
  group_by(gender) %>% 
  summarize(total = n()) %>% 
  arrange(desc(total))

sims_gender_plot <- ggplot(sims_gender, aes(fct_reorder(gender, total), total)) +
  geom_col(fill = "blue",
           alpha = 0.7) +
  scale_y_continuous(limits = c(0, 600),
                     breaks = c(0, 200, 400, 600)) +
  coord_flip() +
  labs(x = "",
       y = "Total")
```

```{r, include=TRUE}
ggplotly(sims_gender_plot)
```

### Sims - Age

```{r, include=FALSE}
sims_concussion_data %>% 
  group_by(age) %>% 
  summarize(total = n()) %>% 
  reactable(
    columns = list(
      age = colDef(name = "Age",
                      align = "center"),
      total = colDef(name = "Total",
                     align = "center",
                     format = colFormat(suffix = " concussions"))),
    pagination = TRUE,
    striped = TRUE,
    outlined = TRUE,
    compact = TRUE,
    highlight = TRUE,
    bordered = TRUE
    )
```

```{r, include=FALSE}
sims_age <- sims_concussion_data %>% 
  mutate(age = as.factor(age)) %>% 
  group_by(age) %>% 
  summarize(total = n()) %>% 
  arrange(desc(total))



sims_age_plot <- ggplot(sims_age, aes(fct_reorder(age, total), total)) +
  geom_col(fill = "blue",
           alpha = 0.7) +
  coord_flip() +
  labs(x = "Age",
       y = "Total")
```

```{r, include=TRUE}
ggplotly(sims_age_plot)
```

### Sims - League

```{r, include=FALSE}
sims_concussion_data %>% 
  group_by(league) %>% 
  summarize(total = n()) %>% 
  arrange(desc(total)) %>% 
  reactable(
    columns = list(
      league = colDef(name = "League",
                      align = "center"),
      total = colDef(name = "Total",
                     align = "center",
                     format = colFormat(suffix = " concussions"))),
    pagination = TRUE,
    striped = TRUE,
    outlined = TRUE,
    compact = TRUE,
    highlight = TRUE,
    bordered = TRUE
    )
```

```{r, include=FALSE}
sims_league <- sims_concussion_data %>% 
  group_by(league) %>% 
  summarize(total = n()) %>% 
  arrange(desc(total))

sims_league_plot <- ggplot(sims_league, aes(fct_reorder(league, total), total)) +
  geom_col(fill = "blue",
           alpha = 0.7) +
  scale_y_continuous(limits = c(0, 500),
                     breaks = c(0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500)) +
  coord_flip() +
  labs(x = "",
       y = "Total")
```

```{r, include=TRUE}
ggplotly(sims_league_plot)
```

### Sims - School

```{r}
sims_concussion_data %>% 
  group_by(school) %>% 
  summarize(total = n()) %>% 
  arrange(desc(total)) %>% 
  reactable(
    columns = list(
      school = colDef(name = "School",
                      align = "center"),
      total = colDef(name = "Total",
                     align = "center",
                     format = colFormat(suffix = " concussions"))),
    pagination = TRUE,
    striped = TRUE,
    outlined = TRUE,
    compact = TRUE,
    highlight = TRUE,
    bordered = TRUE,
    searchable = TRUE
    )
```

### Sims - Sport

```{r}
sims_concussion_data %>% 
  group_by(sport) %>% 
  summarize(total = n()) %>% 
  arrange(desc(total)) %>% 
  reactable(
    columns = list(
      sport = colDef(name = "Sport",
                      align = "center"),
      total = colDef(name = "Total",
                     align = "center",
                     format = colFormat(suffix = " concussions"))),
    pagination = TRUE,
    striped = TRUE,
    outlined = TRUE,
    compact = TRUE,
    highlight = TRUE,
    bordered = TRUE,
    searchable = TRUE
    )
```

### Sims - Sport Level

```{r, include=FALSE}
sims_concussion_data %>% 
  group_by(level) %>% 
  summarize(total = n()) %>% 
  arrange(desc(total)) %>% 
  reactable(
    columns = list(
      level = colDef(name = "Level",
                      align = "center"),
      total = colDef(name = "Total",
                     align = "center",
                     format = colFormat(suffix = " concussions"))),
    pagination = TRUE,
    striped = TRUE,
    outlined = TRUE,
    compact = TRUE,
    highlight = TRUE,
    bordered = TRUE
    )
```

```{r, include=FALSE}
sims_level <- sims_concussion_data %>% 
  group_by(level) %>% 
  summarize(total = n()) %>% 
  arrange(desc(total))

sims_level_plot <- ggplot(sims_level, aes(fct_reorder(level, total), total)) +
  geom_col(fill = "blue",
           alpha = 0.7) +
  scale_y_continuous(limits = c(0, 500),
                     breaks = c(0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500)) +
  coord_flip() +
  labs(x = "",
       y = "Total")
```

```{r, include=TRUE}
ggplotly(sims_level_plot)
```

### Sims - RTL Summary 

```{r, include=TRUE}
create_react_time(sims_concussion_data, dys_btwn_onset_rtp_3)
```

### Sims - RTL Plot 

```{r, include=FALSE}
rtl_smry_plot <- ggplot(sims_concussion_data, aes(dys_btwn_onset_rtp_3)) +
  geom_histogram(fill = "#56B4E9",
                color = "white", 
                alpha = 0.9,
                bins = 10) +
  facet_wrap(~gender, nrow = 1) +
  labs(x = "Days to Complete RTL",
       y = "")
```

```{r, include=TRUE}
ggplotly(rtl_smry_plot)
```

### Sims - RTP Summary 

```{r, include=TRUE}
create_react_time(sims_concussion_data, dys_btwn_onset_rtp_7)
```

### Sims - RTP Plot

```{r, include=FALSE}
rtp_smry_plot <- ggplot(sims_concussion_data, aes(dys_btwn_onset_rtp_7)) +
  geom_histogram(fill = "#56B4E9",
                color = "white", 
                alpha = 0.9,
                bins = 10) +
  facet_wrap(~gender, nrow = 1) +
  labs(x = "Days to Complete RTP",
       y = "")
```

```{r, include=TRUE}
ggplotly(rtp_smry_plot)
```


# One Post-Injury Test 

Sidebar {.sidebar}
------------

**_Description:_** This tab provides summaries and visualizations of PCSS severity scores for the 9,991 concussion cases where the individual completed one post-injury test during recovery. 

Row {.tabset}
-----------------------------------------------------------------------

### Total Symptom Score Histogram 

```{r, include=FALSE}
head(one_impact_test)

score_hist <- function(df, x) {
  ggplot(df, aes({{x}})) +
  geom_histogram(fill = "#56B4E9",
                color = "white", 
                alpha = 0.9,
                bins = 25) +
    labs(x = "Symptom Severity",
         y = "Number of Individuals")
}

gender_hist <- function(df, x) {
  ggplot(df, aes({{x}})) +
  geom_histogram(fill = "#56B4E9",
                color = "white", 
                alpha = 0.9,
                bins = 25) +
    facet_wrap(~gender) +
    labs(x = "Symptom Severity",
         y = "")
}

```

```{r, include=TRUE}
ggplotly(score_hist(one_impact_test, total_symptom_score_post_injury_1))

```

### Total Symptom Score Summary

```{r, include=TRUE}
create_react(one_impact_test, total_symptom_score_post_injury_1)
```

### Total Symptom Score Summary - Gender 

```{r, include=FALSE}
gender_symptom_tbl <- function(df, x) {
  df %>% 
  group_by(gender) %>% 
  summarize(mean = mean({{x}}),
            sd = sd({{x}}),
            min = min({{x}}),
            max = max({{x}}),
            total = length({{x}})) %>%
  mutate(mean = as.numeric(mean),
         sd = as.numeric(sd),
         min = as.numeric(min),
         max = as.numeric(max),
         total = as.numeric(total)) %>% 
  reactable(
    columns = list(
      gender = colDef(name = "Gender"),
      mean = colDef(name = "Mean",
                    format = colFormat(digits = 2, separators = TRUE)),
      sd = colDef(name = "SD",
                  format = colFormat(digits = 2, separators = TRUE)),
      min = colDef(name = "Min",
                   format = colFormat(separators = TRUE)),
      max = colDef(name = "Max",
                   format = colFormat(separators = TRUE)),
      total = colDef(name = "Total",
                   format = colFormat(separators = TRUE, suffix = " concussions"))),
    pagination = TRUE,
    striped = TRUE,
    outlined = TRUE,
    compact = TRUE,
    highlight = TRUE,
    bordered = TRUE
  )
}

gender_symptom_tbl(one_impact_test, total_symptom_score_post_injury_1)

```

```{r, include=TRUE}
gender_symptom_tbl(one_impact_test, total_symptom_score_post_injury_1)
```

### Total Symptom Score Gender Visual Comparison

```{r, include=TRUE}
ggplotly(gender_hist(one_impact_test, total_symptom_score_post_injury_1))
```

Row {.tabset}
-----------------------------------------------------------------------

### Headache-Migraine Cluster Score Histogram 

```{r, include=TRUE}
ggplotly(score_hist(one_impact_test, headache_migraine_cluster_score_post_injury_1))
```

### Headache-Migraine Cluster Score Summary

```{r, include=TRUE}
create_react(one_impact_test, headache_migraine_cluster_score_post_injury_1)
```

### Headache-Migraine Cluster Score Summary - Gender 

```{r, include=TRUE}
gender_symptom_tbl(one_impact_test, headache_migraine_cluster_score_post_injury_1)
```

### Headache-Migraine Score Gender Visual Comparison

```{r, include=TRUE}
ggplotly(gender_hist(one_impact_test, headache_migraine_cluster_score_post_injury_1))
```


Row {.tabset}
-----------------------------------------------------------------------

### Cognitive Cluster Score Histogram 

```{r, include=TRUE}
ggplotly(score_hist(one_impact_test, cognitive_cluster_score_post_injury_1))
```

### Cognitive Cluster Score Summary

```{r, include=TRUE}
create_react(one_impact_test, cognitive_cluster_score_post_injury_1)
```

### Cognitive Cluster Score Summary - Gender 

```{r, include=TRUE}
gender_symptom_tbl(one_impact_test, cognitive_cluster_score_post_injury_1)
```

### Cognitive Score Gender Visual Comparison

```{r, include=TRUE}
ggplotly(gender_hist(one_impact_test, cognitive_cluster_score_post_injury_1))
```

Row {.tabset}
-----------------------------------------------------------------------

### Anxiety-Mood Cluster Score Histogram 

```{r, include=TRUE}
ggplotly(score_hist(one_impact_test, anxiety_mood_cluster_score_post_injury_1))
```

### Anxiety-Mood Cluster Score Summary

```{r, include=TRUE}
create_react(one_impact_test, anxiety_mood_cluster_score_post_injury_1)
```

### Anxiety-Mood Cluster Score Summary - Gender 

```{r, include=TRUE}
gender_symptom_tbl(one_impact_test, anxiety_mood_cluster_score_post_injury_1)
```

### Anxiety-Mood Score Gender Visual Comparison

```{r, include=TRUE}
ggplotly(gender_hist(one_impact_test, anxiety_mood_cluster_score_post_injury_1))
```

Row {.tabset}
-----------------------------------------------------------------------

### Ocular-Motor Cluster Score Histogram 

```{r, include=TRUE}
ggplotly(score_hist(one_impact_test, ocular_motor_cluster_score_post_injury_1))
```

### Ocular-Motor Cluster Score Summary

```{r, include=TRUE}
create_react(one_impact_test, ocular_motor_cluster_score_post_injury_1)
```

### Ocular-Motor Cluster Score Summary - Gender 

```{r, include=TRUE}
gender_symptom_tbl(one_impact_test, ocular_motor_cluster_score_post_injury_1)
```

### Ocular-Motor Score Gender Visual Comparison

```{r, include=TRUE}
ggplotly(gender_hist(one_impact_test, ocular_motor_cluster_score_post_injury_1))
```

Row {.tabset}
-----------------------------------------------------------------------

### Vestibular Cluster Score Histogram 

```{r, include=TRUE}
ggplotly(score_hist(one_impact_test, vestibular_cluster_score_post_injury_1))
```

### Vestibular Cluster Score Summary

```{r, include=TRUE}
create_react(one_impact_test, vestibular_cluster_score_post_injury_1)
```

### Vestibular Cluster Score Summary - Gender 

```{r, include=TRUE}
gender_symptom_tbl(one_impact_test, vestibular_cluster_score_post_injury_1)
```

### Vestibular Score Gender Visual Comparison

```{r, include=TRUE}
ggplotly(gender_hist(one_impact_test, vestibular_cluster_score_post_injury_1))
```

Row {.tabset}
-----------------------------------------------------------------------

### Sleep Cluster Score Histogram 

```{r, include=TRUE}
ggplotly(score_hist(one_impact_test, sleep_cluster_score_post_injury_1))
```

### Sleep Cluster Score Summary

```{r, include=TRUE}
create_react(one_impact_test, sleep_cluster_score_post_injury_1)
```

### Sleep Cluster Score Summary - Gender 

```{r, include=TRUE}
gender_symptom_tbl(one_impact_test, sleep_cluster_score_post_injury_1)
```

### Sleep Score Gender Visual Comparison

```{r, include=TRUE}
ggplotly(gender_hist(one_impact_test, sleep_cluster_score_post_injury_1))
```

# Two Post-Injury Tests 

Sidebar {.sidebar}
------------

**_Description:_** This tab provides summaries and visualizations of PCSS severity scores for the 5,295 concussion cases where the individual completed two post-injury tests during recovery. 

Across all symptom clusters and the total symptom score, post-injury 1 symptom severity was significantly higher than post-injury 2 symptom severity. 



Row {.tabset}
-----------------------------------------------------------------------

### Total Symptom Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, total_symptom_score_post_injury_1))
```

### Total Symptom Score Test 1 Summary

```{r, include=TRUE}
create_react(two_impact_test, total_symptom_score_post_injury_1)
```

### Total Symptom Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, total_symptom_score_post_injury_2))
```

### Total Symptom Score Test 2 Summary

```{r, include=TRUE}
create_react(two_impact_test, total_symptom_score_post_injury_2)
```

### Boxplot Comparison 

```{r, include=FALSE}

bxp_t_test <- function(df, x, y) {
  ggplot(df, aes({{x}}, {{y}}, color = {{y}})) +
    geom_boxplot() +
    geom_jitter(position = position_jitter(0.15)) +
    labs(x = "",
         y = "Symptom Severity") +
    theme(legend.position = "none") +
    stat_compare_means(method = "t.test", paired = TRUE, hjust = -0.3)
}

two_impact_total_symptom_score <- two_impact_test %>% 
  select(2, 3, 4, 5, 57, 58) %>% 
  pivot_longer(
    cols = c(5:6),
    names_to = "test",
    names_prefix = "total_symptom_score_",
    values_to = "score"
  )

bxp_t_test(two_impact_total_symptom_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_t_test(two_impact_total_symptom_score, test, score))
```

### *T*-Test Results 

```{r, include=FALSE}
two_impact_test_total_symptom_score_1 <- two_impact_test$total_symptom_score_post_injury_1
two_impact_test_total_symptom_score_2 <- two_impact_test$total_symptom_score_post_injury_2

two_impact_test_total_symptom_score_res <- t.test(two_impact_test_total_symptom_score_1,
                                                  two_impact_test_total_symptom_score_2,
                                                  paired = TRUE)

two_impact_test_total_symptom_score_res
```

```{r, include=TRUE}
two_impact_test_total_symptom_score_res 
```


Row {.tabset}
-----------------------------------------------------------------------

### Headache-Migraine Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, headache_migraine_cluster_score_post_injury_1))
```

### Headache-Migraine Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(two_impact_test, headache_migraine_cluster_score_post_injury_1)
```

### Headache-Migraine Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, headache_migraine_cluster_score_post_injury_2))
```

### Headache-Migraine Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(two_impact_test, headache_migraine_cluster_score_post_injury_2)
```

### Boxplot Comparison 

```{r, include=FALSE}
two_impact_headache_migraine_cluster_score <- two_impact_test %>% 
  select(2, 3, 4, 5, 59, 60) %>% 
  pivot_longer(
    cols = c(5:6),
    names_to = "test",
    names_prefix = "headache_migraine_cluster_score_",
    values_to = "score"
  )

bxp_t_test(two_impact_headache_migraine_cluster_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_t_test(two_impact_headache_migraine_cluster_score, test, score))
```

### *T*-Test Results 

```{r, include=FALSE}
two_impact_test_headache_migraine_cluster_score_1 <- two_impact_test$headache_migraine_cluster_score_post_injury_1

two_impact_test_headache_migraine_cluster_score_2 <- two_impact_test$headache_migraine_cluster_score_post_injury_2

two_impact_test_headache_migraine_cluster_score_res <- t.test(two_impact_test_headache_migraine_cluster_score_1,
       two_impact_test_headache_migraine_cluster_score_2,
       paired = TRUE)

two_impact_test_headache_migraine_cluster_score_res 
```

```{r, include=TRUE}
two_impact_test_headache_migraine_cluster_score_res
```


Row {.tabset}
-----------------------------------------------------------------------

### Cognitive Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, cognitive_cluster_score_post_injury_1))
```

### Cognitive Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(two_impact_test, cognitive_cluster_score_post_injury_1)
```

### Cognitive Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, cognitive_cluster_score_post_injury_2))
```

### Cognitive Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(two_impact_test, cognitive_cluster_score_post_injury_2)
```

### Boxplot Comparison 

```{r, include=FALSE}
two_impact_cognitive_cluster_score <- two_impact_test %>% 
  select(2, 3, 4, 5, 61, 62) %>% 
  pivot_longer(
    cols = c(5:6),
    names_to = "test",
    names_prefix = "cognitive_cluster_score_",
    values_to = "score"
  )

bxp_t_test(two_impact_cognitive_cluster_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_t_test(two_impact_cognitive_cluster_score, test, score))
```

### *T*-Test Results 

```{r, include=FALSE}
two_impact_test_cognitive_cluster_score_1 <- two_impact_test$cognitive_cluster_score_post_injury_1

two_impact_test_cognitive_cluster_score_2 <- two_impact_test$cognitive_cluster_score_post_injury_2

two_impact_test_cognitive_cluster_score_res <- t.test(two_impact_test_cognitive_cluster_score_1,
       two_impact_test_cognitive_cluster_score_2,
       paired = TRUE)

two_impact_test_cognitive_cluster_score_res 
```

```{r, include=TRUE}
two_impact_test_cognitive_cluster_score_res
```


Row {.tabset}
-----------------------------------------------------------------------

### Anxiety-Mood Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, anxiety_mood_cluster_score_post_injury_1))
```

### Anxiety-Mood Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(two_impact_test, anxiety_mood_cluster_score_post_injury_1)
```

### Anxiety-Mood Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, anxiety_mood_cluster_score_post_injury_2))
```

### Anxiety-Mood Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(two_impact_test, anxiety_mood_cluster_score_post_injury_2)
```

### Boxplot Comparison 

```{r, include=FALSE}
two_impact_anxiety_mood_cluster_score <- two_impact_test %>% 
  select(2, 3, 4, 5, 63, 64) %>% 
  pivot_longer(
    cols = c(5:6),
    names_to = "test",
    names_prefix = "anxiety_mood_cluster_score_",
    values_to = "score"
  )

bxp_t_test(two_impact_anxiety_mood_cluster_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_t_test(two_impact_anxiety_mood_cluster_score, test, score))
```

### *T*-Test Results 

```{r, include=FALSE}
two_impact_test_anxiety_mood_cluster_score_1 <- two_impact_test$anxiety_mood_cluster_score_post_injury_1

two_impact_test_anxiety_mood_cluster_score_2 <- two_impact_test$anxiety_mood_cluster_score_post_injury_2

two_impact_test_anxiety_mood_cluster_score_res <- t.test(two_impact_test_anxiety_mood_cluster_score_1,
       two_impact_test_anxiety_mood_cluster_score_2,
       paired = TRUE)

two_impact_test_anxiety_mood_cluster_score_res 
```

```{r, include=TRUE}
two_impact_test_anxiety_mood_cluster_score_res
```


Row {.tabset}
-----------------------------------------------------------------------

### Ocular-Motor Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, ocular_motor_cluster_score_post_injury_1))
```

### Ocular-Motor Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(two_impact_test, ocular_motor_cluster_score_post_injury_1)
```

### Ocular-Motor Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, ocular_motor_cluster_score_post_injury_2))
```

### Ocular-Motor Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(two_impact_test, ocular_motor_cluster_score_post_injury_2)
```

### Boxplot Comparison 

```{r, include=FALSE}
two_impact_ocular_motor_cluster_score <- two_impact_test %>% 
  select(2, 3, 4, 5, 65, 66) %>% 
  pivot_longer(
    cols = c(5:6),
    names_to = "test",
    names_prefix = "ocular_motor_cluster_score_",
    values_to = "score"
  )

bxp_t_test(two_impact_ocular_motor_cluster_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_t_test(two_impact_ocular_motor_cluster_score, test, score))
```

### *T*-Test Results 

```{r, include=FALSE}
two_impact_test_ocular_motor_cluster_score_1 <- two_impact_test$ocular_motor_cluster_score_post_injury_1

two_impact_test_ocular_motor_cluster_score_2 <- two_impact_test$ocular_motor_cluster_score_post_injury_2

two_impact_test_ocular_motor_cluster_score_res <- t.test(two_impact_test_ocular_motor_cluster_score_1,
       two_impact_test_ocular_motor_cluster_score_2,
       paired = TRUE)

two_impact_test_ocular_motor_cluster_score_res 
```

```{r, include=TRUE}
two_impact_test_ocular_motor_cluster_score_res
```


Row {.tabset}
-----------------------------------------------------------------------

### Vestibular Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, vestibular_cluster_score_post_injury_1))
```

### Vestibular Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(two_impact_test, vestibular_cluster_score_post_injury_1)
```

### Vestibular Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, vestibular_cluster_score_post_injury_2))
```

### Vestibular Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(two_impact_test, vestibular_cluster_score_post_injury_2)
```

### Boxplot Comparison 

```{r, include=FALSE}
two_impact_vestibular_cluster_score <- two_impact_test %>% 
  select(2, 3, 4, 5, 67, 68) %>% 
  pivot_longer(
    cols = c(5:6),
    names_to = "test",
    names_prefix = "vestibular_cluster_score_",
    values_to = "score"
  )

bxp_t_test(two_impact_vestibular_cluster_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_t_test(two_impact_vestibular_cluster_score, test, score))
```

### *T*-Test Results 

```{r, include=FALSE}
two_impact_test_vestibular_cluster_score_1 <- two_impact_test$vestibular_cluster_score_post_injury_1

two_impact_test_vestibular_cluster_score_2 <- two_impact_test$vestibular_cluster_score_post_injury_2

two_impact_test_vestibular_cluster_score_res <- t.test(two_impact_test_vestibular_cluster_score_1,
       two_impact_test_vestibular_cluster_score_2,
       paired = TRUE)

two_impact_test_vestibular_cluster_score_res 
```

```{r, include=TRUE}
two_impact_test_vestibular_cluster_score_res
```


Row {.tabset}
-----------------------------------------------------------------------

### Sleep Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, sleep_cluster_score_post_injury_1))
```

### Sleep Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(two_impact_test, sleep_cluster_score_post_injury_1)
```

### Sleep Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(two_impact_test, sleep_cluster_score_post_injury_2))
```

### Sleep Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(two_impact_test, sleep_cluster_score_post_injury_2)
```

### Boxplot Comparison 

```{r, include=FALSE}
two_impact_sleep_cluster_score <- two_impact_test %>% 
  select(2, 3, 4, 5, 69, 70) %>% 
  pivot_longer(
    cols = c(5:6),
    names_to = "test",
    names_prefix = "sleep_cluster_score_",
    values_to = "score"
  )

bxp_t_test(two_impact_sleep_cluster_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_t_test(two_impact_sleep_cluster_score, test, score))
```

### *T*-Test Results 

```{r, include=FALSE}
two_impact_test_sleep_cluster_score_1 <- two_impact_test$sleep_cluster_score_post_injury_1

two_impact_test_sleep_cluster_score_2 <- two_impact_test$sleep_cluster_score_post_injury_2

two_impact_test_sleep_cluster_score_res <- t.test(two_impact_test_sleep_cluster_score_1,
                                                  two_impact_test_sleep_cluster_score_2,
                                                  paired = TRUE)
       
       

two_impact_test_sleep_cluster_score_res 
```

```{r, include=TRUE}
two_impact_test_sleep_cluster_score_res
```

# Three Post-Injury Tests 

Sidebar {.sidebar}
------------

**_Description:_** This tab provides summaries and visualizations of PCSS severity scores for the 2,228 concussion cases where the individual completed three post-injury tests during recovery. 

Across all symptom clusters and the total symptom score, post-injury 1 symptom severity was significantly higher than post-injury 2 and post-injury 3 symptom severity. Additionally, differences in symptom cluster and total symptom severity scores were significantly different between post-injury 2 and post-injury 3.  



Row {.tabset}
-----------------------------------------------------------------------

### Total Symptom Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, total_symptom_score_post_injury_1))
```

### Total Symptom Score Test 1 Summary

```{r, include=TRUE}
create_react(three_impact_test, total_symptom_score_post_injury_1)
```

### Total Symptom Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, total_symptom_score_post_injury_2))
```

### Total Symptom Score Test 2 Summary

```{r, include=TRUE}
create_react(three_impact_test, total_symptom_score_post_injury_2)
```

### Total Symptom Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, total_symptom_score_post_injury_3))
```

### Total Symptom Score Test 3 Summary

```{r, include=TRUE}
create_react(three_impact_test, total_symptom_score_post_injury_3)
```

### Boxplot Comparison 

```{r, include=FALSE}

bxp_anova <- function(df, x, y) {
  ggplot(df, aes({{x}}, {{y}}, color = {{y}})) +
    geom_boxplot() +
    geom_jitter(position = position_jitter(0.15)) +
    labs(x = "",
         y = "Symptom Severity") +
    theme(legend.position = "none") 
}

three_impact_total_symptom_score <- three_impact_test %>% 
  select(2, 3, 4, 5, 6, 83, 84, 85) %>% 
  pivot_longer(
    cols = c(6:8),
    names_to = "test",
    names_prefix = "total_symptom_score_",
    values_to = "score"
  )

bxp_anova(three_impact_total_symptom_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_anova(three_impact_total_symptom_score, test, score))
```

### Outliers 

```{r, include=FALSE}
three_impact_total_symptom_score_outliers <- three_impact_total_symptom_score %>% 
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 7, 8, 9)

outlier_tbl <- function(df) {
  df %>% 
  reactable(
    columns = list(
      test = colDef(name = "Test",
                    align = "center"),
      passport_id = colDef(name = "Passport ID",
                           align = "center"),
      score = colDef(name = "Score",
                     align = "center"),
      is.outlier = colDef(name = "Outlier Status",
                          align = "center"),
      is.extreme = colDef(name = "Extreme Outlier Status",
                          align = "center")),
    pagination = TRUE,
    striped = TRUE,
    outlined = TRUE,
    compact = TRUE,
    highlight = TRUE,
    bordered = TRUE,
    searchable = TRUE
  )
}

outlier_tbl(three_impact_total_symptom_score_outliers)
```

```{r, include=TRUE}
outlier_tbl(three_impact_total_symptom_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
three_impact_total_symptom_score_res <- anova_test(three_impact_total_symptom_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(three_impact_total_symptom_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
three_impact_total_symptom_score_pwc <- three_impact_total_symptom_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

three_impact_total_symptom_score_pwc <- three_impact_total_symptom_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
three_impact_total_symptom_score_pwc %>% 
  reactable()
```

```{r, include=FALSE}
three_impact_total_symptom_score_pwc <- three_impact_total_symptom_score_pwc %>% 
  add_xy_position(x = "test")


ggplot(three_impact_total_symptom_score, aes(test, score, color = score)) +
    geom_boxplot() +
    geom_jitter(position = position_jitter(0.15)) +
    stat_pvalue_manual(three_impact_total_symptom_score_pwc) +
    labs(x = "",
         y = "Symptom Severity",
         subtitle = get_test_label(three_impact_total_symptom_score_res, detailed = TRUE),
         caption = get_pwc_label(three_impact_total_symptom_score_pwc)) +
    theme(legend.position = "none") 

```

Row {.tabset}
-----------------------------------------------------------------------

### Headache-Migraine Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, headache_migraine_cluster_score_post_injury_1))
```

### Headache-Migraine Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(three_impact_test, headache_migraine_cluster_score_post_injury_1)
```

### Headache-Migraine Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, headache_migraine_cluster_score_post_injury_2))
```

### Headache-Migraine Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(three_impact_test, headache_migraine_cluster_score_post_injury_2)
```

### Headache-Migraine Cluster Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, headache_migraine_cluster_score_post_injury_3))
```

### Headache-Migraine Cluster Score Test 3 Summary

```{r, include=TRUE}
create_react(three_impact_test, headache_migraine_cluster_score_post_injury_3)
```

### Boxplot Comparison 

```{r, include=FALSE}

three_impact_headache_migraine_cluster_score <- three_impact_test %>% 
  select(2, 3, 4, 5, 6, 86, 87, 88) %>% 
  pivot_longer(
    cols = c(6:8),
    names_to = "test",
    names_prefix = "headache_migraine_cluster_score_",
    values_to = "score"
  )

```

```{r, include=TRUE}
ggplotly(bxp_anova(three_impact_headache_migraine_cluster_score, test, score))
```

### Outliers 

```{r, include=FALSE}
three_impact_headache_migraine_cluster_score_outliers <- three_impact_headache_migraine_cluster_score %>% 
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 7, 8, 9)
```

```{r, include=TRUE}
outlier_tbl(three_impact_headache_migraine_cluster_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
three_impact_headache_migraine_cluster_score_res <- anova_test(three_impact_headache_migraine_cluster_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(three_impact_headache_migraine_cluster_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
three_impact_headache_migraine_cluster_score_pwc <- three_impact_headache_migraine_cluster_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

three_impact_headache_migraine_cluster_score_pwc <- three_impact_headache_migraine_cluster_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
three_impact_headache_migraine_cluster_score_pwc %>% 
  reactable()
```


Row {.tabset}
-----------------------------------------------------------------------

### Cognitive Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, cognitive_cluster_score_post_injury_1))
```

### Cognitive Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(three_impact_test, cognitive_cluster_score_post_injury_1)
```

### Cognitive Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, cognitive_cluster_score_post_injury_2))
```

### Cognitive Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(three_impact_test, cognitive_cluster_score_post_injury_2)
```

### Cognitive Cluster Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, cognitive_cluster_score_post_injury_3))
```

### Cognitive Cluster Score Test 3 Summary

```{r, include=TRUE}
create_react(three_impact_test, cognitive_cluster_score_post_injury_3)
```

### Boxplot Comparison 

```{r, include=FALSE}

three_impact_cognitive_cluster_score <- three_impact_test %>% 
  select(2, 3, 4, 5, 6, 89, 90, 91) %>% 
  pivot_longer(
    cols = c(6:8),
    names_to = "test",
    names_prefix = "cognitive_cluster_score_",
    values_to = "score"
  )

```

```{r, include=TRUE}
ggplotly(bxp_anova(three_impact_cognitive_cluster_score, test, score))
```

### Outliers 

```{r, include=FALSE}
three_impact_cognitive_cluster_score_outliers <- three_impact_cognitive_cluster_score %>% 
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 7, 8, 9)
```

```{r, include=TRUE}
outlier_tbl(three_impact_cognitive_cluster_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
three_impact_cognitive_cluster_score_res <- anova_test(three_impact_cognitive_cluster_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(three_impact_cognitive_cluster_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
three_impact_cognitive_cluster_score_pwc <- three_impact_cognitive_cluster_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

three_impact_cognitive_cluster_score_pwc <- three_impact_cognitive_cluster_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
three_impact_cognitive_cluster_score_pwc %>% 
  reactable()
```


Row {.tabset}
-----------------------------------------------------------------------

### Anxiety-Mood Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, anxiety_mood_cluster_score_post_injury_1))
```

### Anxiety-Mood Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(three_impact_test, anxiety_mood_cluster_score_post_injury_1)
```

### Anxiety-Mood Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, anxiety_mood_cluster_score_post_injury_2))
```

### Anxiety-Mood Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(three_impact_test, anxiety_mood_cluster_score_post_injury_2)
```

### Anxiety-Mood Cluster Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, anxiety_mood_cluster_score_post_injury_3))
```

### Anxiety-Mood Cluster Score Test 3 Summary

```{r, include=TRUE}
create_react(three_impact_test, anxiety_mood_cluster_score_post_injury_3)
```

### Boxplot Comparison 

```{r, include=FALSE}

three_impact_anxiety_mood_cluster_score <- three_impact_test %>% 
  select(2, 3, 4, 5, 6, 92, 93, 94) %>% 
  pivot_longer(
    cols = c(6:8),
    names_to = "test",
    names_prefix = "anxiety_mood_cluster_score_",
    values_to = "score"
  )

```

```{r, include=TRUE}
ggplotly(bxp_anova(three_impact_anxiety_mood_cluster_score, test, score))
```

### Outliers 

```{r, include=FALSE}
three_impact_anxiety_mood_cluster_score_outliers <- three_impact_anxiety_mood_cluster_score %>% 
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 7, 8, 9)
```

```{r, include=TRUE}
outlier_tbl(three_impact_anxiety_mood_cluster_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
three_impact_anxiety_mood_cluster_score_res <- anova_test(three_impact_anxiety_mood_cluster_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(three_impact_anxiety_mood_cluster_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
three_impact_anxiety_mood_cluster_score_pwc <- three_impact_anxiety_mood_cluster_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

three_impact_anxiety_mood_cluster_score_pwc <- three_impact_anxiety_mood_cluster_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
three_impact_anxiety_mood_cluster_score_pwc %>% 
  reactable()
```

Row {.tabset}
-----------------------------------------------------------------------

### Ocular-Motor Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, ocular_motor_cluster_score_post_injury_1))
```

### Ocular-Motor Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(three_impact_test, ocular_motor_cluster_score_post_injury_1)
```

### Ocular-Motor Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, ocular_motor_cluster_score_post_injury_2))
```

### Ocular-Motor Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(three_impact_test, ocular_motor_cluster_score_post_injury_2)
```

### Ocular-Motor Cluster Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, ocular_motor_cluster_score_post_injury_3))
```

### Ocular-Motor Cluster Score Test 3 Summary

```{r, include=TRUE}
create_react(three_impact_test, ocular_motor_cluster_score_post_injury_3)
```

### Boxplot Comparison 

```{r, include=FALSE}

three_impact_ocular_motor_cluster_score <- three_impact_test %>% 
  select(2, 3, 4, 5, 6, 95, 96, 97) %>% 
  pivot_longer(
    cols = c(6:8),
    names_to = "test",
    names_prefix = "ocular_motor_cluster_score_",
    values_to = "score"
  )

```

```{r, include=TRUE}
ggplotly(bxp_anova(three_impact_ocular_motor_cluster_score, test, score))
```

### Outliers 

```{r, include=FALSE}
three_impact_ocular_motor_cluster_score_outliers <- three_impact_ocular_motor_cluster_score %>% 
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 7, 8, 9)
```

```{r, include=TRUE}
outlier_tbl(three_impact_ocular_motor_cluster_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
three_impact_ocular_motor_cluster_score_res <- anova_test(three_impact_ocular_motor_cluster_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(three_impact_ocular_motor_cluster_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
three_impact_ocular_motor_cluster_score_pwc <- three_impact_ocular_motor_cluster_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

three_impact_ocular_motor_cluster_score_pwc <- three_impact_ocular_motor_cluster_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
three_impact_ocular_motor_cluster_score_pwc %>% 
  reactable()
```

Row {.tabset}
-----------------------------------------------------------------------

### Vestibular Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, vestibular_cluster_score_post_injury_1))
```

### Vestibular Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(three_impact_test, vestibular_cluster_score_post_injury_1)
```

### Vestibular Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, vestibular_cluster_score_post_injury_2))
```

### Vestibular Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(three_impact_test, vestibular_cluster_score_post_injury_2)
```

### Vestibular Cluster Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, vestibular_cluster_score_post_injury_3))
```

### Vestibular Cluster Score Test 3 Summary

```{r, include=TRUE}
create_react(three_impact_test, vestibular_cluster_score_post_injury_3)
```

### Boxplot Comparison 

```{r, include=FALSE}

three_impact_vestibular_cluster_score <- three_impact_test %>% 
  select(2, 3, 4, 5, 6, 98, 99, 100) %>% 
  pivot_longer(
    cols = c(6:8),
    names_to = "test",
    names_prefix = "vestibular_cluster_score_",
    values_to = "score"
  )

```

```{r, include=TRUE}
ggplotly(bxp_anova(three_impact_vestibular_cluster_score, test, score))
```

### Outliers 

```{r, include=FALSE}
three_impact_vestibular_cluster_score_outliers <- three_impact_vestibular_cluster_score %>% 
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 7, 8, 9)
```

```{r, include=TRUE}
outlier_tbl(three_impact_vestibular_cluster_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
three_impact_vestibular_cluster_score_res <- anova_test(three_impact_vestibular_cluster_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(three_impact_vestibular_cluster_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
three_impact_vestibular_cluster_score_pwc <- three_impact_vestibular_cluster_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

three_impact_vestibular_cluster_score_pwc <- three_impact_vestibular_cluster_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
three_impact_vestibular_cluster_score_pwc %>% 
  reactable()
```


Row {.tabset}
-----------------------------------------------------------------------

### Sleep Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, sleep_cluster_score_post_injury_1))
```

### Sleep Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(three_impact_test, sleep_cluster_score_post_injury_1)
```

### Sleep Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, sleep_cluster_score_post_injury_2))
```

### Sleep Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(three_impact_test, sleep_cluster_score_post_injury_2)
```

### Sleep Cluster Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(three_impact_test, sleep_cluster_score_post_injury_3))
```

### Sleep Cluster Score Test 3 Summary

```{r, include=TRUE}
create_react(three_impact_test, sleep_cluster_score_post_injury_3)
```

### Boxplot Comparison 

```{r, include=FALSE}

three_impact_sleep_cluster_score <- three_impact_test %>% 
  select(2, 3, 4, 5, 6, 101, 102, 103) %>% 
  pivot_longer(
    cols = c(6:8),
    names_to = "test",
    names_prefix = "sleep_cluster_score_",
    values_to = "score"
  )

```

```{r, include=TRUE}
ggplotly(bxp_anova(three_impact_sleep_cluster_score, test, score))
```

### Outliers 

```{r, include=FALSE}
three_impact_sleep_cluster_score_outliers <- three_impact_sleep_cluster_score %>% 
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 7, 8, 9)
```

```{r, include=TRUE}
outlier_tbl(three_impact_sleep_cluster_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
three_impact_sleep_cluster_score_res <- anova_test(three_impact_sleep_cluster_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(three_impact_sleep_cluster_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
three_impact_sleep_cluster_score_pwc <- three_impact_sleep_cluster_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

three_impact_sleep_cluster_score_pwc <- three_impact_sleep_cluster_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
three_impact_sleep_cluster_score_pwc %>% 
  reactable()
```


# Four Post-Injury Tests 

Sidebar {.sidebar}
------------

**_Description:_** This tab provides summaries and visualizations of PCSS severity scores for the 780 concussion cases where the individual completed three post-injury tests during recovery. 

Across all symptom clusters and the total symptom score, post-injury 1 symptom severity was significantly higher than post-injury 2, post-injury 3, and post-injury 4 symptom severity. Additionally, differences in symptom cluster and total symptom severity scores were significantly different between post-injury 2, post-injury 3, and post-injury 4 with the exception of one pairwise comparison (ocular-motor symptom cluster severity between post-injury 3 and post-injury 4).  


Row {.tabset}
-----------------------------------------------------------------------

### Total Symptom Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, total_symptom_score_post_injury_1))
```

### Total Symptom Score Test 1 Summary

```{r, include=TRUE}
create_react(four_impact_test, total_symptom_score_post_injury_1)
```

### Total Symptom Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, total_symptom_score_post_injury_2))
```

### Total Symptom Score Test 2 Summary

```{r, include=TRUE}
create_react(four_impact_test, total_symptom_score_post_injury_2)
```

### Total Symptom Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, total_symptom_score_post_injury_3))
```

### Total Symptom Score Test 3 Summary

```{r, include=TRUE}
create_react(four_impact_test, total_symptom_score_post_injury_3)
```

### Total Symptom Score Test 4 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, total_symptom_score_post_injury_4))
```

### Total Symptom Score Test 4 Summary

```{r, include=TRUE}
create_react(four_impact_test, total_symptom_score_post_injury_4)
```

### Boxplot Comparison 

```{r, include=FALSE}

four_impact_total_symptom_score <- four_impact_test %>% 
  select(2, 3, 4, 5, 6, 7, 109, 110, 111, 112) %>% 
  pivot_longer(
    cols = c(7:10),
    names_to = "test",
    names_prefix = "total_symptom_score_",
    values_to = "score"
  )

bxp_anova(four_impact_total_symptom_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_anova(four_impact_total_symptom_score, test, score))
```

### Outliers 

```{r, include=FALSE}
four_impact_total_symptom_score_outliers <- four_impact_total_symptom_score %>% 
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 8, 9, 10)

```

```{r, include=TRUE}
outlier_tbl(four_impact_total_symptom_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
four_impact_total_symptom_score_res <- anova_test(four_impact_total_symptom_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(four_impact_total_symptom_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
four_impact_total_symptom_score_pwc <- four_impact_total_symptom_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

four_impact_total_symptom_score_pwc <- four_impact_total_symptom_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
four_impact_total_symptom_score_pwc %>% 
  reactable()
```


Row {.tabset}
-----------------------------------------------------------------------

### Headache-Migraine Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, headache_migraine_cluster_score_post_injury_1))
```

### Headache-Migraine Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(four_impact_test, headache_migraine_cluster_score_post_injury_1)
```

### Headache-Migraine Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, headache_migraine_cluster_score_post_injury_2))
```

### Headache-Migraine Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(four_impact_test, headache_migraine_cluster_score_post_injury_2)
```

### Headache-Migraine Cluster Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, headache_migraine_cluster_score_post_injury_3))
```

### Headache-Migraine Cluster Score Test 3 Summary

```{r, include=TRUE}
create_react(four_impact_test, headache_migraine_cluster_score_post_injury_3)
```

### Headache-Migraine Cluster Score Test 4 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, headache_migraine_cluster_score_post_injury_4))
```

### Headache-Migraine Cluster Score Test 4 Summary

```{r, include=TRUE}
create_react(four_impact_test, headache_migraine_cluster_score_post_injury_4)
```

### Boxplot Comparison 

```{r, include=FALSE}

four_impact_headache_migraine_cluster_score <- four_impact_test %>% 
  select(2, 3, 4, 5, 6, 7, 113, 114, 115, 116) %>% 
  pivot_longer(
    cols = c(7:10),
    names_to = "test",
    names_prefix = "headache_migraine_cluster_score_",
    values_to = "score"
  )

bxp_anova(four_impact_headache_migraine_cluster_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_anova(four_impact_headache_migraine_cluster_score, test, score))
```

### Outliers 

```{r, include=FALSE}
four_impact_headache_migraine_cluster_score_outliers <- four_impact_headache_migraine_cluster_score %>% 
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 8, 9, 10)

```

```{r, include=TRUE}
outlier_tbl(four_impact_headache_migraine_cluster_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
four_impact_headache_migraine_cluster_score_res <- anova_test(four_impact_headache_migraine_cluster_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(four_impact_headache_migraine_cluster_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
four_impact_headache_migraine_cluster_score_pwc <- four_impact_headache_migraine_cluster_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

four_impact_headache_migraine_cluster_score_pwc <- four_impact_headache_migraine_cluster_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
four_impact_headache_migraine_cluster_score_pwc %>% 
  reactable()
```

Row {.tabset}
-----------------------------------------------------------------------

### Cognitive Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, cognitive_cluster_score_post_injury_1))
```

### Cognitive Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(four_impact_test, cognitive_cluster_score_post_injury_1)
```

### Cognitive Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, cognitive_cluster_score_post_injury_2))
```

### Cognitive Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(four_impact_test, cognitive_cluster_score_post_injury_2)
```

### Cognitive Cluster Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, cognitive_cluster_score_post_injury_3))
```

### Cognitive Cluster Score Test 3 Summary

```{r, include=TRUE}
create_react(four_impact_test, cognitive_cluster_score_post_injury_3)
```

### Cognitive Cluster Score Test 4 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, cognitive_cluster_score_post_injury_4))
```

### Cognitive Cluster Score Test 4 Summary

```{r, include=TRUE}
create_react(four_impact_test, cognitive_cluster_score_post_injury_4)
```

### Boxplot Comparison 

```{r, include=FALSE}

four_impact_cognitive_cluster_score <- four_impact_test %>% 
  select(2, 3, 4, 5, 6, 7, 117, 118, 119, 120) %>% 
  pivot_longer(
    cols = c(7:10),
    names_to = "test",
    names_prefix = "cognitive_cluster_score_",
    values_to = "score"
  )

bxp_anova(four_impact_cognitive_cluster_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_anova(four_impact_cognitive_cluster_score, test, score))
```

### Outliers 

```{r, include=FALSE}
four_impact_cognitive_cluster_score_outliers <- four_impact_cognitive_cluster_score %>% 
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 8, 9, 10)

```

```{r, include=TRUE}
outlier_tbl(four_impact_cognitive_cluster_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
four_impact_cognitive_cluster_score_res <- anova_test(four_impact_cognitive_cluster_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(four_impact_cognitive_cluster_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
four_impact_cognitive_cluster_score_pwc <- four_impact_cognitive_cluster_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

four_impact_cognitive_cluster_score_pwc <- four_impact_cognitive_cluster_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
four_impact_cognitive_cluster_score_pwc %>% 
  reactable()
```


Row {.tabset}
-----------------------------------------------------------------------

### Anxiety-Mood Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, anxiety_mood_cluster_score_post_injury_1))
```

### Anxiety-Mood Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(four_impact_test, anxiety_mood_cluster_score_post_injury_1)
```

### Anxiety-Mood Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, anxiety_mood_cluster_score_post_injury_2))
```

### Anxiety-Mood Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(four_impact_test, anxiety_mood_cluster_score_post_injury_2)
```

### Anxiety-Mood Cluster Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, anxiety_mood_cluster_score_post_injury_3))
```

### Anxiety-Mood Cluster Score Test 3 Summary

```{r, include=TRUE}
create_react(four_impact_test, anxiety_mood_cluster_score_post_injury_3)
```

### Anxiety-Mood Cluster Score Test 4 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, anxiety_mood_cluster_score_post_injury_4))
```

### Anxiety-Mood Cluster Score Test 4 Summary

```{r, include=TRUE}
create_react(four_impact_test, anxiety_mood_cluster_score_post_injury_4)
```

### Boxplot Comparison 

```{r, include=FALSE}

four_impact_anxiety_mood_cluster_score <- four_impact_test %>% 
  select(2, 3, 4, 5, 6, 7, 121, 122, 123, 124) %>% 
  pivot_longer(
    cols = c(7:10),
    names_to = "test",
    names_prefix = "anxiety_mood_cluster_score_",
    values_to = "score"
  )

bxp_anova(four_impact_anxiety_mood_cluster_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_anova(four_impact_anxiety_mood_cluster_score, test, score))
```

### Outliers 

```{r, include=FALSE}
four_impact_anxiety_mood_cluster_score_outliers <- four_impact_anxiety_mood_cluster_score %>%
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 8, 9, 10)

```

```{r, include=TRUE}
outlier_tbl(four_impact_anxiety_mood_cluster_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
four_impact_anxiety_mood_cluster_score_res <- anova_test(four_impact_anxiety_mood_cluster_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(four_impact_anxiety_mood_cluster_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
four_impact_anxiety_mood_cluster_score_pwc <- four_impact_anxiety_mood_cluster_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

four_impact_anxiety_mood_cluster_score_pwc <- four_impact_anxiety_mood_cluster_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
four_impact_anxiety_mood_cluster_score_pwc %>% 
  reactable()
```

Row {.tabset}
-----------------------------------------------------------------------

### Ocular-Motor Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, ocular_motor_cluster_score_post_injury_1))
```

### Ocular-Motor Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(four_impact_test, ocular_motor_cluster_score_post_injury_1)
```

### Ocular-Motor Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, ocular_motor_cluster_score_post_injury_2))
```

### Ocular-Motor Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(four_impact_test, ocular_motor_cluster_score_post_injury_2)
```

### Ocular-Motor Cluster Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, ocular_motor_cluster_score_post_injury_3))
```

### Ocular-Motor Cluster Score Test 3 Summary

```{r, include=TRUE}
create_react(four_impact_test, ocular_motor_cluster_score_post_injury_3)
```

### Ocular-Motor Cluster Score Test 4 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, ocular_motor_cluster_score_post_injury_4))
```

### Ocular-Motor Cluster Score Test 4 Summary

```{r, include=TRUE}
create_react(four_impact_test, ocular_motor_cluster_score_post_injury_4)
```

### Boxplot Comparison 

```{r, include=FALSE}

four_impact_ocular_motor_cluster_score <- four_impact_test %>% 
  select(2, 3, 4, 5, 6, 7, 125, 126, 127, 128) %>% 
  pivot_longer(
    cols = c(7:10),
    names_to = "test",
    names_prefix = "ocular_motor_cluster_score_",
    values_to = "score"
  )

bxp_anova(four_impact_ocular_motor_cluster_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_anova(four_impact_ocular_motor_cluster_score, test, score))
```

### Outliers 

```{r, include=FALSE}
four_impact_ocular_motor_cluster_score_outliers <- four_impact_ocular_motor_cluster_score %>%
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 8, 9, 10)

```

```{r, include=TRUE}
outlier_tbl(four_impact_ocular_motor_cluster_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
four_impact_ocular_motor_cluster_score_res <- anova_test(four_impact_ocular_motor_cluster_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(four_impact_ocular_motor_cluster_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
four_impact_ocular_motor_cluster_score_pwc <- four_impact_ocular_motor_cluster_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

four_impact_ocular_motor_cluster_score_pwc <- four_impact_anxiety_mood_cluster_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
four_impact_ocular_motor_cluster_score_pwc %>% 
  reactable()
```

Row {.tabset}
-----------------------------------------------------------------------

### Vestibular Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, vestibular_cluster_score_post_injury_1))
```

### Vestibular Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(four_impact_test, vestibular_cluster_score_post_injury_1)
```

### Vestibular Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, vestibular_cluster_score_post_injury_2))
```

### Vestibular Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(four_impact_test, vestibular_cluster_score_post_injury_2)
```

### Vestibular Cluster Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, vestibular_cluster_score_post_injury_3))
```

### Vestibular Cluster Score Test 3 Summary

```{r, include=TRUE}
create_react(four_impact_test, vestibular_cluster_score_post_injury_3)
```

### Vestibular Cluster Score Test 4 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, vestibular_cluster_score_post_injury_4))
```

### Vestibular Cluster Score Test 4 Summary

```{r, include=TRUE}
create_react(four_impact_test, vestibular_cluster_score_post_injury_4)
```

### Boxplot Comparison 

```{r, include=FALSE}

four_impact_vestibular_cluster_score <- four_impact_test %>% 
  select(2, 3, 4, 5, 6, 7, 129, 130, 131, 132) %>% 
  pivot_longer(
    cols = c(7:10),
    names_to = "test",
    names_prefix = "vestibular_cluster_score_",
    values_to = "score"
  )

bxp_anova(four_impact_vestibular_cluster_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_anova(four_impact_vestibular_cluster_score, test, score))
```

### Outliers 

```{r, include=FALSE}
four_impact_vestibular_cluster_score_outliers <- four_impact_vestibular_cluster_score %>%
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 8, 9, 10)

```

```{r, include=TRUE}
outlier_tbl(four_impact_vestibular_cluster_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
four_impact_vestibular_cluster_score_res <- anova_test(four_impact_vestibular_cluster_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(four_impact_vestibular_cluster_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
four_impact_vestibular_cluster_score_pwc <- four_impact_vestibular_cluster_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

four_impact_vestibular_cluster_score_pwc <- four_impact_vestibular_cluster_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
four_impact_vestibular_cluster_score_pwc %>% 
  reactable()
```

Row {.tabset}
-----------------------------------------------------------------------

### Sleep Cluster Score Test 1 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, sleep_cluster_score_post_injury_1))
```

### Sleep Cluster Score Test 1 Summary

```{r, include=TRUE}
create_react(four_impact_test, sleep_cluster_score_post_injury_1)
```

### Sleep Cluster Score Test 2 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, sleep_cluster_score_post_injury_2))
```

### Sleep Cluster Score Test 2 Summary

```{r, include=TRUE}
create_react(four_impact_test, sleep_cluster_score_post_injury_2)
```

### Sleep Cluster Score Test 3 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, sleep_cluster_score_post_injury_3))
```

### Sleep Cluster Score Test 3 Summary

```{r, include=TRUE}
create_react(four_impact_test, sleep_cluster_score_post_injury_3)
```

### Sleep Cluster Score Test 4 

```{r, include=TRUE}
ggplotly(score_hist(four_impact_test, sleep_cluster_score_post_injury_4))
```

### Sleep Cluster Score Test 4 Summary

```{r, include=TRUE}
create_react(four_impact_test, sleep_cluster_score_post_injury_4)
```

### Boxplot Comparison 

```{r, include=FALSE}

four_impact_sleep_cluster_score <- four_impact_test %>% 
  select(2, 3, 4, 5, 6, 7, 133, 134, 135, 136) %>% 
  pivot_longer(
    cols = c(7:10),
    names_to = "test",
    names_prefix = "sleep_cluster_score_",
    values_to = "score"
  )

bxp_anova(four_impact_sleep_cluster_score, test, score)
```

```{r, include=TRUE}
ggplotly(bxp_anova(four_impact_sleep_cluster_score, test, score))
```

### Outliers 

```{r, include=FALSE}
four_impact_sleep_cluster_score_outliers <- four_impact_sleep_cluster_score %>%
  group_by(test) %>% 
  identify_outliers(score) %>% 
  select(1, 3, 8, 9, 10)

```

```{r, include=TRUE}
outlier_tbl(four_impact_sleep_cluster_score_outliers)
```

### ANOVA 

```{r, include=FALSE}
four_impact_sleep_cluster_score_res <- anova_test(four_impact_sleep_cluster_score, 
                                   dv = score,
                                   wid = passport_id, 
                                   within = test)
```

```{r, include=TRUE}
get_anova_table(four_impact_sleep_cluster_score_res) %>% 
  reactable()
```

### Pairwise Comparisons 

```{r, include=FALSE}
four_impact_sleep_cluster_score_pwc <- four_impact_sleep_cluster_score %>% 
  pairwise_t_test(
    score ~ test, paired = TRUE,
    p.adjust.method = "bonferroni"
  )

four_impact_sleep_cluster_score_pwc <- four_impact_sleep_cluster_score_pwc %>% 
  mutate_at(vars(statistic), list(~ round(., 2)))
```

```{r, include=TRUE}
four_impact_sleep_cluster_score_pwc %>% 
  reactable()
```